package net.jast.sanitizer.impl;

import net.jast.sanitizer.Sanitizer;
import net.jast.sanitizer.impl.basic.StringSanitizer;

public class CreditCardSanitizer {

    final public static Sanitizer INSTANCE = getInstance();

    // private static final String STR_VISA = "4([0-9]{12,15})";

    // private static final String STR_AMEX = "[0-9]{12,15}";

    private static final String STR_DINERS = "(36[0-9]{2})([0-9]{2})([0-9]{4})([0-9]{4})";

    private static final String STR_ELO = "(636368|504175|438935|451416|636297)([0-9]{3})([0-9]{3})([0-9]{4})";

    private static final String STR_MASTERCARD = "(5[1-5][0-9]{2})([0-9]{4})([0-9]{4})([0-9]{4})";

    private static final String STR_VISA1 = "(000[0-9])([0-9]{3})([0-9]{3})([0-9]{3})";

    private static final String STR_VISA2 = "(4[0-9]{3})([0-9]{4})([0-9]{4})([0-9]{4})";

    public static Sanitizer getInstance() {
        return new StringSanitizer(getPatterns());
    }

    public static String[] getPatterns() {
        return new String[] { STR_MASTERCARD, STR_ELO, STR_VISA1, STR_VISA2, STR_DINERS };
    }
}
